package com.heima.test;

import java.util.ArrayList;

import com.heima.bean.Person;

public class Test3 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ArrayList<Person> list = new ArrayList<>();
		list.add(new Person("aaa",23));
		list.add(new Person("bbb",25));
		list.add(new Person("ccc",24));
		list.add(new Person("ddd",29));
		list.add(new Person("eee",29));
		list.add(new Person("fff",29));
		list.add(new Person("ggg",29));
		list.add(new Person("hhh",29));
		
		ArrayList<Person> wlist = getSingle(list);
		System.out.println(wlist);
	}

	private static ArrayList<Person> getSingle(ArrayList<Person> list) {
		ArrayList<Person> newlist = new ArrayList<>();
		Object[] arr = list.toArray();
		for (int i = arr.length-1; i >= 0; i--) {
			Person s = (Person)arr[i];
			newlist.add(new Person(s.getName(),s.getAge()));
		}
		
		return newlist;
	}

}
